﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NCS.Module.CMS.Library;
using NCS.Library.Utilities;
using NCS.Module.CMS.Library.Definitions;
using NCS.Library;
using NCS.Module.CMS.Library.Distributions;
using NCS.Library.Components.Partner;
using NCS.Module.CMS.Library.Events;
using NCS.Module.CMS.Library.Zones;

namespace NCS.Module.CMS.Web.HomePage
{
    public partial class LeftEventList : CMSWebControl
    {
        int i = 1;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(AppEnv.GetLanguage() == "vi-VN")
            {
                hplCaption.Text = "Chuyên đề";
            }
            else
            {
                hplCaption.Text = "Special Topics";
            }

            DataTable left = EventController.GetAllByNum(0);
            rptEventList.DataSource = left;
            rptEventList.DataBind();
        }


        protected void rptEventList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
             if (e.Item.ItemIndex < 0) return;
            DataRowView currow = (DataRowView)e.Item.DataItem;
            string src_img = ConvertUtility.ToString(currow["Event_Avatar"]) != string.Empty ? MultimediaUtility.GetEventAvatar(currow["Event_Avatar"].ToString()) : "";
            string datetime = "&nbsp;&nbsp;<span style='color:gray;font-size: 10px;'>" + ConvertUtility.ToDateTime(currow["Event_CreateDate"]).ToString("dd/MM/yyyy hh:mm:ss tt") + "</span>";

            Literal ltt = (Literal)e.Item.FindControl("lttImg");
            if (!string.IsNullOrEmpty(src_img) && System.IO.File.Exists(Server.MapPath(src_img)))
            {
                string js_img = "javascript:window.location='" + BuildUrlbyEvent((int)currow["Event_ID"]) + "'";
                ltt.Text = "<img src='" + src_img + "' alt=''   Width='150' onclick=\"" + js_img + "\"/>";
            }
            ltt.Text += "<a href='" + BuildUrlbyEvent((int)currow["Event_ID"]) + "' style='color:#062FAF;font-size:13px;'>";
            ltt.Text += currow["Event_Name"].ToString();
            ltt.Text += datetime + "</a>";
            
        }
    }
}